package com.rt.easyjava.base.modules.timerjob.listen;

import com.rt.easyjava.base.modules.timerjob.config.QuartzManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

//@Configuration
@Slf4j
public class StartJob implements ApplicationListener<ContextRefreshedEvent> {


    @Autowired QuartzManager quartzManager;

    public void run(){
        log.info(">> 启动定时任务...");
        //    QuartzManager.startJobs();
        /*quartzManager.addJob(
                "SpecialPeriodJob",
                "SpecialPeriodJobGroup",
                "SpecialPeriodTrigger",
                "SpecialPeriodTriggerGroup",
                MyQuartzJobBean2.class,
                "0/5 * * * * ?");*/
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        System.out.println("启动定时任务......");
        run();
    }
}
